#pragma once
#include "feDefs.h"
#include "feVector.h"
#include <stdio.h>

class feElement;

class feMesh
{
protected:
	virtual feElement* First() = 0;
	virtual feElement* Next(feElement *iElem) = 0;
	virtual bool	   IsDone(feElement *iElem) = 0;

public:
	
	
	//-------------------------------------------------------------------------------------------------------
	class ElementIterator
	{
		feMesh *Mesh;
		feElement *CurElem;

	public:
		ElementIterator(feMesh *iMesh) { Mesh = iMesh; }

		feElement* First()		 { CurElem = Mesh->First(); return CurElem; }
		void	   Next()		 { CurElem = Mesh->Next(CurElem); }
		feElement* CurrentItem() { return CurElem; }
		bool	   IsDone()		 { return Mesh->IsDone(CurElem); }
	};


	//-------------------------------------------------------------------------------------------------------
	virtual fePoint& GetNode(int iIndex) = 0;
	virtual int	     NodesCount() = 0;

	virtual ElementIterator GetIterator() { return ElementIterator(this);}
	virtual void			PushElement(feElement *iElement) = 0;
	virtual void			PushNode(fePoint *iPoint) = 0;

	virtual bool SaveToFile(char *iFname) = 0;
	virtual bool LoadFromFile(char *iFname) = 0;	
	
	virtual void ClearMesh() = 0;
	
	virtual ~feMesh() {};

	friend class ElementIterator;
};
